home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / pinfocom_3_0.lha / Source / funcs.c < prev    next >
C/C++ Source or Header  |  1992-10-22  |  2KB  |  130 lines

  1. /* functions.c
  2.  *
  3.  *  ``pinfocom'' -- a portable Infocom Inc. data file interpreter.
  4.  *  Copyright (C) 1987-1992  InfoTaskForce
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 2 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; see the file COPYING.  If not, write to the
  18.  *  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. /*
  22.  * $Header: RCS/funcs.c,v 3.0 1992/10/21 16:56:19 pds Stab $
  23.  */
  24.  
  25. #include    "infocom.h"
  26.  
  27. void
  28. plus A2(word, a, word, b)
  29. {
  30.     store(a + b);
  31. }
  32.  
  33. void
  34. minus A2(word, a, word, b)
  35. {
  36.     store(a - b);
  37. }
  38.  
  39. void
  40. multiply A2(word, a, word, b)
  41. {
  42.     store(a * b);
  43. }
  44.  
  45. void
  46. divide A2(word, a, word, b)
  47. {
  48.     store(a / b);
  49. }
  50.  
  51. void
  52. mod A2(word, a, word, b)
  53. {
  54.     store(a % b);
  55. }
  56.  
  57. void
  58. pi_random A1(word, num)
  59. {
  60.     extern word     random1;
  61.     extern word     random2;
  62.  
  63.     word            temp;
  64.  
  65.     temp = random1 << 1;
  66.     random1 = random2;
  67.     if (random2 & 0x8000)
  68.         ++temp;
  69.     random2 ^= temp;
  70.  
  71.     if (num)
  72.         store(((word)(random2 & 0x7FFF) % num) + 1);
  73.     else
  74.         store(0);
  75. }
  76.  
  77. void
  78. LTE A2(word, a, word, b)
  79. {
  80.     ret_value((signed_word)a < (signed_word)b);
  81. }
  82.  
  83. void
  84. GTE A2(word, a, word, b)
  85. {
  86.     ret_value((signed_word)a > (signed_word)b);
  87. }
  88.  
  89. void
  90. bit A2(word, a, word, b)
  91. {
  92.     ret_value((b & (~a)) == 0);
  93. }
  94.  
  95. void
  96. or A2(word, a, word, b)
  97. {
  98.     store(a | b);
  99. }
  100.  
  101. void
  102. not A1(word, a)
  103. {
  104.     store(~a);
  105. }
  106.  
  107. void
  108. and A2(word, a, word, b)
  109. {
  110.     store(a & b);
  111. }
  112.  
  113. void
  114. compare A2(word, num, const word *, param)
  115. {
  116.     const word *pp;
  117.     Bool equal = 0;
  118.  
  119.     for (pp = ¶m[1]; num > 1; ++pp, --num)
  120.         equal |= (*param == *pp);
  121.  
  122.     ret_value(equal);
  123. }
  124.  
  125. void
  126. cp_zero A1(word, a)
  127. {
  128.     ret_value(a == 0);
  129. }
  130.